package com.ldl.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ldl.object.AutoCompleteDO;
import com.opensymphony.xwork2.Action;

public class BigautocompleteAction {
	private Map json = new HashMap(); 
	private String keyword;

	public String autoData(){
		
		AutoCompleteDO array[] = new AutoCompleteDO[5];//这个数组里的数据相当于数据库里记录，共5条
		array[0] = new AutoCompleteDO("中国");
		array[1] = new AutoCompleteDO("美国");
		array[2] = new AutoCompleteDO("日本");
		array[3] = new AutoCompleteDO("英国");
		array[4] = new AutoCompleteDO("法国");
		
		List<AutoCompleteDO> resultList = new ArrayList<AutoCompleteDO>();//根据keyword过滤后的数据
		
		for (int i = 0; i < array.length; i++) {
			if(array[i].getTitle().contains(keyword)){
				resultList.add(array[i]);
			}
		}
		
		json.put("data",resultList);
		
		return Action.SUCCESS;
	}

	
	public Map getJson() {
		return json;
	}

	public void setJson(Map json) {
		this.json = json;
	}

	public String getKeyword() {
		return keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}
	
}
